{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "从一集分类的结果中，导出子表。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "from utils import glm4_vllm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2024-09-02 19:33:19,746 - modelscope - INFO - PyTorch version 2.3.0 Found.\n",
      "2024-09-02 19:33:19,747 - modelscope - INFO - Loading ast index from /home/jie/.cache/modelscope/ast_indexer\n",
      "2024-09-02 19:33:19,761 - modelscope - INFO - Loading done! Current index file version is 1.14.0, with md5 9f53011443b7fabdfb807148bea6e1f2 and a total number of 976 components indexed\n"
     ]
    }
   ],
   "source": [
    "from settings import *\n",
    "from settings import TOTAL_CLS, TOTAL_PROMPT\n",
    "\n",
    "from utils import load_obj\n",
    "\n",
    "from datasets import load_dataset\n",
    "\n",
    "import os\n",
    "\n",
    "os.environ[\"HTTP_PROXY\"] = \"http://127.0.0.1:7890\"\n",
    "os.environ[\"HTTPS_PROXY\"] = \"http://127.0.0.1:7890\"\n",
    "\n",
    "CSV_FILE = \"output/氢能产业链企业_9k_0902.csv\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataset = load_dataset(\n",
    "    'csv', \n",
    "    data_files=CSV_FILE, \n",
    "    split='train'\n",
    "    )"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "看有多少个子类别"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'储氢-运输-注氢'"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dataset[0][\"氢能产业链节点\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "3e5abb09ce164aa7a6166ad08fda24dd",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Filter:   0%|          | 0/18442 [00:00<?, ? examples/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "tmp = dataset.filter(lambda x: \"制氢\" in x['氢能产业链节点'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 大模型推理\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "llm",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
